"use strict";

const Controller = require('../common/admin')

class OrderController extends Controller {

  tableName='order'

  async getOrderList() {
    const {cur_page=1, each_page=10} = this.ctx.request.query
    let orderData = await this.consultPage(null, null, {curPage: cur_page, eachPage: each_page})

    this.tableName = 'order_goods'
    let orderGPm = []
    orderData.list.forEach((orderItem) => {
      orderGPm.push(this.consult({order_id: orderItem.order_id}))
    });
    let orderGoodsList = await Promise.all(orderGPm)

    orderData.list.forEach((orderItem, index) => {
      orderItem.orderGoodsList = orderGoodsList[index]
    })

    // console.log('goodsList', result);
    this.resData(0, '商品列表获取成功', orderData)
  }

}

module.exports = OrderController